/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
 var isSymmetric = function(root) {
    function compare(left,right){
        if(!left && !right){
            return true;
        }
        if(!left || !right || left.val !== right.val){
            return false;
        }
        return compare(left.left,right.right) && compare(left.right,right.left);
    }
    return compare(root.left,root.right)
};